﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
using TestingPlatForm.MissionContrl.Entity;
using TestingPlatForm.MissionContrl.Models;

namespace TestingPlatForm.MissionContrl.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        public DelegateCommand<ItemsBar> NavigateCommand { get; private set; }
        private readonly IRegionManager regionManager;
        private ObservableCollection<ItemsBar> _ItemsBars = new ObservableCollection<ItemsBar>();

        public ObservableCollection<ItemsBar> ItemsBars
        {
            get { return _ItemsBars; }
            set { _ItemsBars = value; }
        }

        public MainWindowViewModel(IRegionManager regionManager)
        {
            InitialBars();
            NavigateCommand = new DelegateCommand<ItemsBar>(Navigate);
            this.regionManager = regionManager;
        }

        private void Navigate(ItemsBar obj)
        {
            if (obj == null || string.IsNullOrWhiteSpace(obj.NameSpace))
                return;

            regionManager.Regions["MainRegion"].RequestNavigate(obj.NameSpace);

        }

        public void InitialBars()
        {
            ItemsBars.Add(new ItemsBar() { Icon = "Home", Title = "首页", NameSpace = "IndexView" });
            ItemsBars.Add(new ItemsBar() { Icon = "Calculator", Title = "换算器", NameSpace = "CalculatorView" });
            ItemsBars.Add(new ItemsBar() { Icon = "NotebookEdit", Title = "HTTP", NameSpace = "MemoView" });
            ItemsBars.Add(new ItemsBar() { Icon = "AlphaACircle", Title = "俯仰角", NameSpace = "RAHView" });
            ItemsBars.Add(new ItemsBar() { Icon = "Cog", Title = "链路设置", NameSpace = "ConnectWayView" });
            ItemsBars.Add(new ItemsBar() { Icon = "Cog", Title = "设置", NameSpace = "SettingsView" });
        }

    }
}
